<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/CMS.Master" Inherits="Shop.Framework.Page.CMS_ProductListPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <title>Product Listing</title>
    <link href="/Content/product_cms_style.css" rel="Stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="productList_wrapper">
        <h2>
            <%=CurrentCategory.Name%>
            Product Listing</h2>
        <%if (TotalPage != 0) { %>
        <ul class="paging-style">
            <%for (int count = 1; count <= TotalPage; count++) { %>
            <li><a href="/cms/<%=IdCategory%>/product-list/<%=count%>">
                <div>
                    <%=count%></div>
            </a></li>
            <%} %>
        </ul>
        <%} else { %>
        <h5>
            No products yet</h5>
        <%} %>
        <div class="clear">
        </div>
        <hr />
        <table id="product-table" class="left">
            <thead>
                <tr>
                    <td colspan="2">
                        Name
                    </td>
                    <td>
                        Price
                    </td>
                    <td colspan="2">
                        Taxed Price
                    </td>
                </tr>
            </thead>
            <tbody>
                <%
                int start = 0, cont = (CurrentPage * 10) - 10;
                foreach (var p in ProductList) { %>
                <%if (start < (CurrentPage * 10) && cont <= start) {%>
                <tr>
                    <td colspan="2">
                        <%=p.Name %>
                    </td>
                    <td>
                        <%=p.Price.ToString("C")%>
                    </td>
                    <td>
                        <%=p.TaxedPrice.ToString("C") %>
                    </td>
                    <td>
                        <input type="button" value="Edit" onclick="window.location='/cms/<%=IdCategory%>/product-<%=p.IdProduct %>';" />
                    </td>
                </tr>
                <%} start += 1;%>
                <%}%>
            </tbody>
        </table>
    </div>
    <div class="clear">
    </div>
    <hr />    
    <b>Page <%=CurrentPage %> of <%= TotalPage%> </b><input type="button" value="Add new product" onclick="window.location = '/cms/maintainance/new-product/<%=IdCategory %>';" />
    <br />
    <div class="clear">
    <a onclick="history.go(-1)" class="nav_link">Back to previous</a>
</asp:Content>
